'use strict';
const dayjs = require("dayjs");
module.exports = app => {
    const { STRING, INTEGER, TINYINT } = app.Sequelize;
    return app.model.define(
        'companyModel',
        {
            id: {type: INTEGER, primaryKey: true, autoIncrement: true},
            comp_name: STRING(50),
            is_deleted: TINYINT(1),
            check_time:{
                type: app.Sequelize.DATE,
                allowNull: true,
                get() {
                    return dayjs(this.getDataValue('check_time')).format('YYYY-MM-DD');
                }
            }
        },
        {
            tableName: 'company',
            timestamps: true, // 启用时间戳(createdAt, updatedAt)
            updatedAt: false, // 不想要 updatedAt
            createdAt: false, // 想要  createdAt 但是希望名称叫做 created_at
        }
    );
};
